package com.hbnu.thread;

public class Product implements Runnable{

    private Box box = new Box();

    public Product(Box box) {
        this.box = box;
    }

    @Override
    public void run() {
        System.out.println("生产者开始生产产品");
        while(true){
            try {
                Thread.sleep((int) Math.random() * 1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            box.addProduct();
        }
    }
}
